home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 September
/
PCWorld_2006-09_cd.bin
/
v cisle
/
hexer
/
mpth_17.exe
/
{app}
/
scripts
/
Structure Viewer
/
bmp.mps
next >
Wrap
Text File
|
2006-03-19
|
4KB
|
163 lines
option title, "Windows bitmap (.bmp) structure"
=
=
= Tiny Hexer script for .BMP structure view in
= mirkes.de's tiny hex editor
=
= (C) markus stephany, tinyhexer[at]mirkes[dot]de
=
option GlobalVars, 1
option ReadTags, 1
option target, structureviewer
= open active editor and goto current position/0
var editor file
editor = fileopen('::current')
if ((param_count > 0) and (dword(params(0))==1))
fileseek editor, 0
else
fileseek editor, filegetprop(editor, 'selstart')
endif
var start dword
start = filegetprop(editor, 'position')
= open browser window
var browser file
browser = fileopen('::browser', 'c')
filesetprop browser, 'accepttags', 1
filewrite browser "<font color=",'"',"blue",'"',"><b><u>Bitmap Graphic structure:</u></b></font>\n\n"
filesetprop browser, 'accepttags', 0
filewrite browser "File: '",filegetprop(editor, 'filename'),"'\nPosition: ",start,"\n\n"
= read the BMP header
var _word word _dword dword _text text
fileread editor _word
if _word != 0x4d42
error 'Unknown file format'
endif
= print file header
filewrite browser "struct tagBITMAPFILEHEADER {\n"
_text = data2text(_word)
copytags _text _word
filewrite browser " WORD bfType\t'",_text,"'\t\t(",_word,");\n"
fileread editor _dword
filewrite browser " DWORD bfSize\t",_dword,";\n"
fileread editor _word
filewrite browser " WORD bfReserved1\t",_word,";\n"
fileread editor _word
filewrite browser " WORD bfReserved2\t",_word,";\n"
fileread editor _dword
_text = 'bfOffbits': tagvar _text, _dword, 0
filewrite browser " DWORD ",_text,"\t",_dword,";\n"
filewrite browser "}\n\n"
= print info header
filewrite browser "struct tagBITMAPINFOHEADER {\n"
fileread editor _dword
filewrite browser " DWORD biSize\t\t",_dword,";\n"
fileread editor _dword
filewrite browser " LONG biWidth\t",_dword,"\t("
call DECOUT @_dword
filewrite browser ");\n"
fileread editor _dword
filewrite browser " LONG biHeight\t",_dword,"\t("
call DECOUT @_dword
filewrite browser ");\n"
fileread editor _word
filewrite browser " WORD biPlanes\t",_word,";\n"
= get bit per pixel
var bpp word
fileread editor bpp
filewrite browser " WORD biBitCount\t",bpp,";\t\t("
call DECOUT @bpp
filewrite browser ");\n"
fileread editor _dword
filewrite browser " DWORD biCompression\t",_dword,";\n"
fileread editor _dword
filewrite browser " DWORD biSizeImage\t",_dword,";\n"
fileread editor _dword
filewrite browser " LONG biXPPerMeter\t",_dword,";\n"
fileread editor _dword
filewrite browser " LONG biYPPerMeter\t",_dword,";\n"
fileread editor _dword
filewrite browser " DWORD biClrUsed\t",_dword,";\n"
fileread editor _dword
filewrite browser " DWORD biClrImportant\t",_dword,";\n"
filewrite browser "}\n\n"
if bpp <= 8
= print color table header
= calculate number of colors (2 ** bits = 2 << (bits -1))
bpp = 2 << (bpp - 1)
filewrite browser "Color table ("
call DECOUTNOCOL @bpp
filewrite browser " colors):\n"
filewrite browser "=====================================================\n"
filewrite browser "\nINDEX\t\tBLUE\tGREEN\tRED\tRES.\n\n"
= print color table
loop COLOROUT bpp
endif
fileclose browser
fileclose editor
end
= decimal output
@@DECOUT
number_radix = 10
number_prefix = ''
var _r1 varref
pop _r1
filewrite browser deref(_r1)
number_prefix = '0x'
number_radix = 16
return
= decimal output without number marking
@@DECOUTNOCOL
number_radix = 10
number_prefix = ''
pop _r1
filewrite browser text(deref(_r1))
number_prefix = ''
number_radix = 16
return
= output a color line
@@COLOROUT
if loop < 100
filewrite browser ' '
if loop < 10
filewrite browser ' '
endif
endif
var l byte
l = loop
call DECOUTNOCOL @l
filewrite browser ")\t\t"
fileread editor l
filewrite browser l, "\t"
fileread editor l
filewrite browser l, "\t"
fileread editor l
filewrite browser l, "\t"
fileread editor l
filewrite browser l, "\n"
return